﻿Imports System.Data.Linq
Imports System.Linq

Public Class ContTypeRepository
    Private dc As New TanNamChinhDataContext

    Public Sub New()
        dc = GeneralClassDAL.dc
    End Sub

    Public Function SelectAllRecord() As IQueryable(Of tblContType)
        Dim companies = From p In dc.tblContTypes
                        Where p.IsActive = True
                        Select p
        Return companies
    End Function

    Public Function SelectRecordById(ByVal id As Integer) As tblContType
        Return dc.tblContTypes.SingleOrDefault(Function(p As tblContType) p.ID_ContType = id)
    End Function

    Public Sub Insert(ByVal obj As tblContType)
        dc.tblContTypes.InsertOnSubmit(obj)
        dc.SubmitChanges()
    End Sub

    Public Sub Update(ByVal obj As tblContType)
        dc.Refresh(RefreshMode.KeepChanges, obj)
        dc.SubmitChanges(ConflictMode.ContinueOnConflict)
    End Sub
End Class
